[script]
n0=;
n1=;      this section deals with all "on text" type events
n2=;
n3=alias freenum {
n4=  ; return the first available line # for the repeat text detection
n5=  ; for this nick on this channel and save it
n6=  set %max $readini $mircdirrepeat.ini $1 [ maxsaid $+ [ $2 ] ]
n7=  %c = 0
n8=  :nx
n9=  inc %c
n10=  set %text $readini $mircdirrepeat.ini $1 [ [ $2 ] $+ [ %c ] ]
n11=  if %text = $null {
n12=    if (%c > %max) writeini $mircdirrepeat.ini $1 [ maxsaid $+ [ $2 ] ] %c
n13=    return %c
n14=  }
n15=  else goto nx
n16=}
n17=alias justsaid {
n18=  ; did nick $2 just say text $3- on channel $1?
n19=  ; yeah, kinda sucks to have to use an .ini file
n20=  ; the first one I did used all mIRC variables instead... it was uglier to look at
n21=  ; but faster, but on a busy channel it could fill up the variables section very
n22=  ; quickly, a very bad situation! (it's already pretty full as it is...  even with only
n23=  ; one custom channel defined, along with the other options, it is already around
n24=  ; 10k, or 30% full.  Oh well... this works too.
n25=  %max = $readini $mircdirrepeat.ini $1 [ maxsaid $+ [ $2 ] ]
n26=  if %max = $null return $null
n27=  %num = %max + 1
n28=  %found = $false
n29=  :nx
n30=  dec %num
n31=  set %text2 $readini $mircdirrepeat.ini $1 [ [ $2 ] $+ [ %num ] ]
n32=  if ((%text2 = $null) && (%found = $false)) dec %num
n33=  if (%text2 != $null) set %found $true
n34=  if (%text2 = $3-) return $readini $mircdirrepeat.ini $1 [ when $+ [ $2 ] $+ [ %num ] ]
n35=  if %num > 1 goto nx
n36=  return $null
n37=}
n38=alias afserv {
n39=  if ($isfsban($2)) {
n40=    inc %atfs [ $+ [ $mask($2,3) ] ] 1 | .timer 1 30 unset %atfs [ $+ [ $mask($2,3) ] ]
n41=    if %atfs [ $+ [ $mask($2,3) ] ] > 3 {
n42=      echo 4 -a Excessive file server requests from $1 $+ , placing on ignore for 5 minutes | alert
n43=      .ignore -cp $mask($2,3) | .timer 1 300 .ignore -r $mask($2,3)
n44=    }
n45=    else {
n46=      if (%fsbreason) {
n47=        .ignore -cp $mask($2,3) | .timer 1 5 .ignore -r $mask($2,3)
n48=        set %reason $fsbanreason($2)
n49=        if %reason != $null raw -q notice $1 :You are banned from this file server: %reason
n50=      }
n51=      echo 4 -a $1 attempted to access your file server! 3(banned, ignoring) | alert
n52=    }
n53=  }
n54=  elseif ($fserv($1) != $null) {
n55=    raw -q notice $1 :One connection at a time please!
n56=    .ignore -cp $mask($2,3) | .timer 1 5 .ignore -r $mask($2,3)
n57=    altech -a %dis10 $+ $1 attempted to open multiple fserve connections! | alert
n58=  }
n59=  else {
n60=    set %fsady [ $+ [ $1 ] ] $mask($2,3)
n61=    fserve $1 %maxgets $3-
n62=  }
n63=}
n64=alias ptxt  {
n65=  if (%urd) {
n66=    z | if $1 = t echo 1 $me < $+ $2 $+ > $strip(*3)
n67=    else if $1 = n echo 1 $me NOTICE: 5,0- $+ $2 $+ - $strip(*3)
n68=    else echo 6 $me 1 ACTION: * $+ $2 $strip(*3)
n69=  }
n70=}
n71=alias iscensored {
n72=  %n = 0
n73=  :nx
n74=  inc %n
n75=  if (%cenword [ $+ [ %n ] ] != $null) {
n76=    if %cenword [ $+ [ %n ] ] isin $strip($1-) return %n
n77=    goto nx
n78=  }
n79=  return 0
n80=}
n81=alias doping {
n82=  if (%numpings > 5) {
n83=    altech -a %dis3 $+ Too many !ping requests! %dis4 Ignoring all of them for 60 seconds
n84=    set %enableping $false
n85=    .timer 1 60 set %enableping $true
n86=    alert | halt
n87=  }
n88=  inc %numpings
n89=  .timer 1 60 unset %numpings
n90=  if (%tvhavepinged [ $+ [ $2 ] ] = $null) {
n91=    set %tvhavepinged [ $+ [ $2 ] ] 1
n92=    .timer 1 60 unset %tvhavepinged [ $+ [ $2 ] ]
n93=    set %pingnick $1 | ping $nick
n94=  }
n95=  else {
n96=    inc %tvhavepinged [ $+ [ $2 ] ]
n97=    if (%tvhavepinged [ $+ [ $2 ] ] > 2) {
n98=      altech -a %dis3 $+ Warning! %dis4 $1 is abusing the !ping feature (ignoring $2 for 60 seconds)
n99=      .ignore -p $2 | .timer 1 60 .ignore -r $2 | alert
n100=    }
n101=  }
n102=}
n103=alias remrepeat {
n104=  remini $mircdirrepeat.ini $1 $2
n105=  remini $mircdirrepeat.ini $1 [ when $+ [ $2 ] ]
n106=}
n107=alias ontext {
n108=  ; all sorts of things to do on text in the channel...
n109=  ; this is done in an alias instead of an ON TEXT event because the same
n110=  ; routine is done for a notice or action also.  It's in an alias so it can be 
n111=  ; called in all 3 cases (one of these is enuff, don't think I wanna deal with 3!)
n112=  if (%haveoptions [ $+ [ $3 ] ] ) set %optchan $3
n113=  else set %optchan other
n114=  utxt $1 $2 $3 $7-
n115=  if (($me isin $7-) && (%alertnick) && ($active != $3)) echo 6 -a $2 $+ @ $+ $3 $+ :13,0 $7-
n116=  if $left($7-,7) = 0,0��� enc $3 $+ _ $+ $1 $2 $7-
n117=  if ((%autofserve1) && ($7- = %autoword1) && ($1 = t)) afserv $2 $6 %fservepath1
n118=  if ((%autofserve2) && ($7- = %autoword2) && ($1 = t)) afserv $2 $6 %fservepath2
n119=  if ((%tsunf [ $+ [ $3 ] ] ) && (**** iswm [ $strip($7-) ] ) && ($ulevel < 18)) {
n120=    if $me isop $3 {
n121=      kick $3 $2 Enough with the  characters!
n122=      if (%ekick) { 
n123=        if (%ckick) set %temp $3
n124=        else set %temp -a 
n125=        altech %temp %dis3 $+ Tsunami Flood! %dis4 Kicked $2 from $3
n126=        alert
n127=      }
n128=      goto skip
n129=    }
n130=  }
n131=  if $me !isop $3 goto skip
n132=  if ((%censorall [ $+ [ %optchan ] ] ) || (%censorunrec [ $+ [ %optchan ] ] )) {
n133=    if (($isfriend($2,$3)) && (%censorunrec [ $+ [ %optchan ] ] )) goto skip
n134=    set %pos $iscensored($7-)
n135=    if %pos != 0 { censorkick $2 $3 %cenword [ $+ [ %pos ] ] | dh }
n136=  }
n137=  if ($isfriend($2,$3)) goto skip
n138=  if (%idlekick [ $+ [ $3 ] ] ) writeini $mircdiridle.ini $3 $2 $ctime
n139=  if (%repeatkick [ $+ [ %optchan ] ] ) {
n140=    if ($len($strip($7-)) <= 3) goto norepeat
n141=    set %saidtext $replace($7-,[,$chr(32)) | set %saidtext $replace(%saidtext,],$chr(32))
n142=    set %saidtext $replace(%saidtext,|,$chr(32))
n143=    set %when $justsaid($3,$2,%saidtext)
n144=    if %when != $null {
n145=      if (%tvrkd [ $+ [ $chan [ $+ [ $nick ] ] ] ] != $true) {
n146=        set %tvrkd [ $+ [ $chan [ $+ [ $nick ] ] ] ] $true
n147=        .timer 1 5 unset %tvrkd [ $+ [ $chan [ $+ [ $nick ] ] ] ]
n148=        kick $3 $2 you said that line $dur(%when) ago!
n149=        if (%ekick) {
n150=          if (%ckick) set %temp $2 %dis3
n151=          else set %temp -a %dis3
n152=          altech %temp $+ Repeat Kick! %dis4 Kicking $2 from $3
n153=        }
n154=        if (%srepeat = ding) ding
n155=        elseif (%srepeat = speak) speak repeat detected, kicking $2 from $nonum($3)
n156=        elseif (%srepeat != none) splay %srepeat
n157=      }
n158=    }
n159=    set %rest $2 $+ $freenum($3,$2)
n160=    writeini $mircdirrepeat.ini $3 %rest %saidtext
n161=    writeini $mircdirrepeat.ini $3 [ when $+ [ %rest ] ] $ctime
n162=    .timer 1 %repeatin [ $+ [ %optchan ] ] remrepeat $3 %rest
n163=  }
n164=  :norepeat
n165=  if (%colorkick [ $+ [ %optchan ] ] ) {
n166=    if $len($7-) != $len($strip($7-)) {
n167=      kick $3 $2 %colorkickmsg
n168=      if (%ekick) {
n169=        if (%ckick) set %temp $3
n170=        else set %temp -a
n171=        altech %temp %dis3 $+ Color Kick! %dis4 Kicked $2 from $3
n172=        if (%scolor = ding) ding
n173=        elseif (%scolor = speak) speak Color Kick, kicked $2 from $nonum($3)
n174=        elseif (%scolor != none) splay %scolor
n175=      }
n176=    }
n177=  }
n178=  if ((%antiexclam [ $+ [ %optchan ] ] ) && ($left($7,1) = !) && ($8 = $null)) {
n179=    kick $3 $2 %antiecxlammsg
n180=    if (%ekick) {
n181=      if (%ckick) set %temp $3
n182=      else set %temp -a
n183=      altech %temp %dis3 $+ Ack!!  Exclamatory Commands! %dis4 Kicking $2 from $3
n184=    }
n185=    if (%sexclam = ding) ding
n186=    elseif (%sexclam = speak) speak exclamatory command, kicking $2 from $nonum($3)
n187=    elseif (%sexclam != none) splay %sexclam
n188=    goto skip
n189=  }
n190=  if ((%capskicker [ $+ [ %optchan ] ] ) || (%longword [ $+ [ %optchan ] ] )) checktext $2 $3 $7-
n191=  if (%textflood [ $+ [ %optchan ] ] ) {
n192=    inc %tvtxtfl [ $+ [ $5 ] ] | .timer 1 %textin unset %tvtxtfl [ $+ [ $5 ] ]
n193=    if (%tvtxtfl [ $+ [ $5 ] ] >= %textis) { 
n194=      kick $3 $2 %textfloodmsg | unset %tvtxtfl [ $+ [ $5 ] ]
n195=      if (%ekick) { 
n196=        if (%ckick) set %temp $3
n197=        else set %temp -a
n198=        altech %temp %dis3 $+ Text Flood! %dis4 Kicking $2 from $3
n199=      }
n200=      if (%stext = ding) ding
n201=      elseif (%stext = speak) speak text flood, kicking $2 from $nonum($3)
n202=      elseif (%stext != none) splay %stext
n203=      goto skip
n204=    }
n205=    elseif (%eflood) altech -s %dis16 $+ Text Flood detector watching $2 %dis17 $+ (offense %tvtxtfl [ $+ [ $5 ] ] $+ )
n206=  }
n207=  :skip
n208=}
n209=alias censorkick {
n210=  if (%ckick) set %temp $2
n211=  else set %temp -a
n212=  if (%banafter [ $+ [ %optchan ] ] ) {
n213=    inc %violations [ $+ [ $1 ] ]
n214=    .timer 1 %censorin [ $+ [ %optchan ] ] unset %violations [ $+ [ $1 ] ]
n215=    if ((%violations [ $+ [ $1 ] ] >= %censoris [ $+ [ %optchan ] ] )) {
n216=      mode $2 +b-o $a3($1) $1 | kick $2 $1 %exccensormsg
n217=      rtb $a3($1) $2
n218=      if (%ekick) altech %temp %dis3 $+ Excessive Censor Violations! %dis4 Banning $1 on $2
n219=      goto done
n220=    }
n221=  }
n222=  kick $2 $1 Auto-Kick on the word " $+ $3- $+ "
n223=  if (%ekick) altech %temp %dis3 $+ Censor Kick! %dis4 Kicking $1 from $2
n224=  :done
n225=}
n226=alias checktext {
n227=  %m = 0 | %caps = 0 | %spc = 0 | %len = $len($3-)
n228=  :nx
n229=  inc %m | set %temp $asc($mid($3-,%m,1))
n230=  if %temp isnum 65-90 { inc %caps | inc %spc }
n231=  elseif %temp != 32 inc %spc
n232=  else %spc = 0
n233=  if ((%spc > %longwordis) && (%longword [ $+ [ %optchan ] ] )) {
n234=    ckick $1 $2 %longwordmsg
n235=    if (%ekick) {
n236=      if (%ckick) set %temp $2 %dis3
n237=      else set %temp -a %dis3
n238=      altech %temp $+ Long Words Suck! %dis4 Kicking $1 from $2
n239=    }
n240=    if (%slong = ding) ding
n241=    elseif (%slong = speak) speak long word detected, kicking $1 from $nonum($2)
n242=    elseif (%slong != none) splay %slong
n243=    goto done
n244=  }
n245=  if %m < %len goto nx
n246=  if ((%caps > %capsis) && (%capskicker [ $+ [ %optchan ] ] )) {
n247=    ckick $1 $2 Ackk! %caps caps!
n248=    if (%ekick) {
n249=      if (%ckick) set %temp $2
n250=      else set %temp -a
n251=      altech %temp %dis3 $+ Excessive Caps! %dis4 Kicking $1 from $2
n252=    }
n253=    if (%scaps = ding) ding
n254=    elseif (%scaps = speak) speak excessive caps, kicking $1 from $nonum($2)
n255=    elseif (%scaps != none) splay %scaps
n256=  }
n257=  :done
n258=}
n259=alias ckick {
n260=  if (%tvjustkicked [ $+ [ $a3($1) ] ] ) { 
n261=    mode $2 -o+b $1 $a3($1) | rtb $a3($1) $2
n262=  }
n263=  else { 
n264=    set %tvjustkicked [ $+ [ $a3($1) ] ] $true
n265=    .timer 1 20 unset set %tvjustkicked [ $+ [ $a3($1) ] ]
n266=  }
n267=  kick $2 $1 $3-
n268=}
n269=alias utxt  {
n270=  if (%urd) {
n271=    z | if $1 = t echo 1 $me $3 $+ : < $+ $2 $+ > $strip(*4)
n272=    else if $1 = n echo 1 $me $3 5,0NOTICE: - $+ $2 $+ - $strip(*4)
n273=    else echo 1 $me $3 ACTION: * $+ $2 $strip(*4)
n274=  }
n275=}
n276=on 1:CHAT:Enter your password.:{
n277=  if (%autoconn [ $+ [ $nick ] ] ) {
n278=    unset %autoconn [ $+ [ $nick ] ]
n279=    msg =$nick %eggpass [ $+ [ $nick ] ]
n280=  }
n281=}
n282=on 40:TEXT:.pass*:?:{
n283=  set %nick $rnick.nick($nick)
n284=  if %nick != $null {
n285=    set %pass $readini $ul password %nick
n286=    if %pass = $null {
n287=      writeini $ul password %nick $2
n288=      raw -q notice $nick :Your password has been saved.
n289=      echo 4 -a Password set for %nick
n290=    }
n291=    else raw -q notice $nick :You already have a password set.  Use .chpass <oldpass> <newpass>
n292=  }
n293=  halt
n294=}
n295=on 20:TEXT:.info*:?:{
n296=  if (%infolines) {
n297=    set %rn $rnick.ady($fulladdress)
n298=    if %rn != $null {
n299=      ; change any [ or ] characters to a | cuz [ and ] mess up .ini files
n300=      writeini $ul info %rn $replace( [ $replace($2-,[,|) ] ,],|)
n301=      raw -q notice $nick :Info set to: $replace( [ $replace($2-,[,|) ] ,],|)
n302=      echo 4 -s Info line set for %rn
n303=    }
n304=    halt
n305=  }
n306=}
n307=on 40:TEXT:.chpass*:?:{
n308=  set %nick $rnick.nick($nick) | if %nick = $null halt
n309=  set %pass $readini $ul password %nick
n310=  if ((%pass = $2) && ($3 != $null)) {
n311=    if $3 = $null raw -q notice $nick :Syntax: .chpass <oldpass> <newpass>
n312=    else {
n313=      writeini $ul password %nick $3
n314=      raw -q notice $nick :Your new password has been saved.
n315=    }
n316=  }
n317=  halt
n318=}
n319=on 40:TEXT:.op*:?:{
n320=  set %nick $rnick.nick($nick) | if %nick = $null halt
n321=  set %pass $readini $ul password %nick
n322=  if (($2 = %pass) && ($2 != $null)) {
n323=    unset %msg
n324=    if $comchan($nick,0) = 0 { raw -q notice $nick :Sorry, I'm not on any of the same channels as you! | halt }
n325=    %i = 0
n326=    :nx
n327=    inc %i
n328=    if $comchan($nick,%i) != $null {
n329=      if $me !isop $comchan($nick,%i) set %msg I am not a channel op
n330=      else {
n331=        if (($isop($nick,$comchan($nick,%i))) && (%oppass [ $+ [ $comchan($nick,%i) ] ] )) {
n332=          if $nick isop $comchan($nick,%i) set %msg you are already an op
n333=          else { set %msg giving ops | mode $comchan($nick,%i) +o $nick }
n334=        }
n335=      }
n336=      if %msg != $null raw -q PRIVMSG $nick :Common channel $comchan($nick,%i) $+ : %msg
n337=      goto nx
n338=    }
n339=  }
n340=  else echo 4 -s $nick requested ops.  Password incorrect, did not op.
n341=  halt
n342=}
n343=on 1:TEXT:!PING:?:if (%enableping) { doping $nick $mask($fulladdress,4) | halt }
n344=on 1:TEXT:!PING:#:if (%enableping) doping $nick $a4($nick)
n345=on 1:TEXT:SEEN*:#:{
n346=  utxt t $nick $chan $1-
n347=  if (%tvignoreseen [ $+ [ $a3($nick) ] ] ) goto done
n348=  if (%seen) {
n349=    inc %tvdidseen [ $+ [ $a3($nick) ] ]
n350=    if %tvdidseen [ $+ [ $a3($nick) ] ] > 3 {
n351=      msg $chan $nick $+ : too many seen requests...  requests from your site will be ignored for 60 seconds
n352=      set %tvignoreseen [ $+ [ $a3($nick) ] ] $true
n353=      .timer 1 30 unset %tvignoreseen [ $+ [ $a3($nick) ] ]
n354=    }
n355=    .timer 1 20 unset %tvdidseen [ $+ [ $a3($nick) ] ]
n356=    if $2 = $nick msg $chan $nick $+ : Trying to find yourself, eh?
n357=    elseif $2 = $me msg $chan $nick $+ : Yeah, whenever I look in a mirror...
n358=    elseif $2 ison $chan msg $chan $nick $+ : $2 is on $chan right now!
n359=    else {
n360=      %i = 0
n361=      :nx
n362=      inc %i
n363=      set %ady $readini $ul address [ [ $2 ] $+ [ %i ] ]
n364=      if %ady != $null {
n365=        if $ialchan(%ady,$chan,1) != $null {
n366=          msg $chan $nick $+ : $2 is $ialchan(%ady,$chan,1).nick $+ , and $ialchan(%ady,$chan,1).nick is on $chan right now!!!
n367=          goto done
n368=        }
n369=        goto nx
n370=      }
n371=    }
n372=    set %temp $readini $ul seen $2
n373=    if %temp = $null msg $chan $nick $+ : I do not know who $2 is.
n374=    else msg $chan $nick $+ : $2 was last here $dur(%temp) ago
n375=  }
n376=  :done
n377=}
n378=;shut-up ban
n379=on @+16:TEXT:*:#:utxt t $nick $chan $1- | kick $chan $nick %shutupmsg
n380=on @+16:NOTICE:*:#:utxt n $nick $chan $1- | kick $chan $nick %shutupmsg
n381=on @+16:ACTION:*:#:utxt a $nick $chan $1- | kick $chan $nick %shutupmsg :>
n382=on 1!:TEXT:*:#:ontext t $nick $chan $ulevel $site $fulladdress $1-
n383=on 1!:ACTION:*:#:ontext a $nick $chan $ulevel $site $fulladdress $1- | :>
n384=on 1!:NOTICE:*:#:ontext n $nick $chan $ulevel $site $fulladdress $1-
n385=on 19:TEXT:.chan:?:{
n386=  if (%tvdidchan [ $+ [ $mask($fulladdress,2) ] ] ) halt
n387=  set %tvdidchan [ $+ [ $mask($fulladdress,2) ] ] $true
n388=  .timer 1 5 unset %tvdidchan [ $+ [ $mask($fulladdress,2) ] ] 
n389=  raw -q notice $nick :I am currently on $dde $ddename channels "" 
n390=  raw -q notice $nick :I am using $server
n391=  halt
n392=}
n393=on 19:TEXT:.invite*:?:{
n394=  if (%tvdidinvite [ $+ [ $mask($fulladdress,2) ] ] ) halt
n395=  set %tvdidinvite [ $+ [ $mask($fulladdress,2) ] ] $true
n396=  .timer 1 5 unset %tvdidinvite [ $+ [ $mask($fulladdress,2) ] ] 
n397=  if $left($2,1) = $chr(35) set %chan $2
n398=  else set %chan $chr(35) $+ $2
n399=  if $isfriend($nick,%chan) {
n400=    if $me ison %chan { invite $nick $2 | echo 4 -a Invited $nick to %chan (requested) }
n401=    else raw -q notice $nick :I am not on %chan
n402=  }
n403=  halt
n404=}
n405=on 1:TEXT:*:?:{
n406=  ptxt t $nick $1-
n407=  if $left($1-,7) = 0,0��� enc ns $nick $1-
n408=  if ((%autofserve1) && ($1- = %autoword1)) { afserv $nick $fulladdress %fservepath1 | halt }
n409=  if ((%autofserve2) && ($1- = %autoword2)) { afserv $nick $fulladdress %fservepath2 | halt }
n410=  if ($away) {
n411=    inc %msgs
n412=    if (%awaylog) {
n413=      writeini $mircdiroptions\away.ini away [ From $+ [ %msgs ] ] $fulladdress
n414=      writeini $mircdiroptions\away.ini away [ Time $+ [ %msgs ] ] $realtime $adate
n415=      writeini $mircdiroptions\away.ini away [ Message $+ [ %msgs ] ] $1-
n416=      echo 5 -a $realtime Message %msgs received from $nick $+ , saved
n417=    }
n418=    else echo 5 -a $realtime Message %msgs received from $nick $+ , (msglog off)
n419=    if (%tvhvm [ $+ [ $nick ] ] != $true) {
n420=      if (%awaylog) msg $nick Sorry, I'm away.  I've been away for $dur(%since) ( $+ %amsg $+ ), but your message has been saved.
n421=      else msg $nick Sorry, I'm away.  I've been away for $dur(%since) ( $+ %amsg $+ ), and I am currently not logging messages.
n422=      set %tvhvm [ $+ [ $nick ] ] $true | .timer 1 30 unset %tvhvm [ $+ [ $nick ] ]
n423=    }
n424=    if (%closeaway) { close -m $nick | halt }
n425=  }
n426=  :>
n427=}
n428=on 1:ACTION:*:?:{
n429=  ptxt a $nick $1-
n430=  if $left($1-,7) = 0,0��� enc na $nick $1- | :>
n431=}
n432=on 1:NOTICE:*:?:ptxt n $nick $1-
n433=on 1:SNOTICE:*:echo %dis18 - $+ $server $+ - %dis19 $+ $1- | halt
